/**
 * 
 */
package com.neal.domain.securities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

/**
 * @author Neal
 * @version 1.0
 * @description 权限
 */
//@Entity
//@Table(name = "SYS_FUNC")
public class Function {

	/** 编号 (主鍵) **/
	@Id
	@Column(name = "FUNC_CODE",length=36)
	private String code;

	/** 名称 **/
	@Column(name = "FUNC_NAME")
	private String name;

	/** 位置 **/
	@Column(name = "ORDER_NO")
	private Integer orderNo;

	/** 父节点 **/
	@ManyToOne
	@JoinColumn(name = "PARENT_ID")
	private Function parent;

	/** 子节点 **/
	@OneToMany(mappedBy = "parent")
	private List<Function> children = new ArrayList<Function>();

	@Transient
	private boolean enable;

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(Integer orderNo) {
		this.orderNo = orderNo;
	}

	public Function getParent() {
		return parent;
	}

	public void setParent(Function parent) {
		this.parent = parent;
	}

	public List<Function> getChildren() {
		return children;
	}

	public void setChildren(List<Function> children) {
		this.children = children;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Function other = (Function) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		return true;
	}

}
